package com.aaa.controller;

import com.aaa.service.T_QuestionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: TT
 * @Date: 2019/3/12 11:19
 * @Version 1.0
 */
@Controller
@RequestMapping("/question/")
public class T_QuestionsController{
@Autowired
    T_QuestionsService service;
    @RequestMapping("go")
    public String go(){
        return "questions/questions";
    }

    @RequestMapping("list")
    @ResponseBody
    public Map  Select(@RequestBody Map map){
        List<Map>  data=service.Select(map);
        Integer   integer=service.Count(map);

        Map map1=new HashMap();
        map1.put("data",data);
        map1.put("total",integer);
        map1.put("years",service.Year());
        map1.put("types",service.type());

        return  map1;
    }
    @RequestMapping("update")
    @ResponseBody
        public  Integer Update(@RequestBody Map map){

            return  service.Update(map);
        }
      @RequestMapping("insert")
      @ResponseBody
    public  Integer Insert(@RequestBody Map map){
        return   service.Insert(map);
      }
        @RequestMapping("del/{id}")
        @ResponseBody
    public Integer Del(@PathVariable Map map){
        return  service.Del(map);
        }
   @RequestMapping("dels/{ids}")
    @ResponseBody
    public Integer dels(@PathVariable String ids){
        String[]  id=ids.split(",");
       System.out.println(id[1]);
       Integer row=null;
       for (int i = 0; i <id.length; i++) {
             row=(Integer) service.dels(id[i]);
       }
        return  row;
    }
}
